import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_ui/src/theme/colors.dart';

import '../FormCreator.dart';

class FormSubmitButton extends StatefulWidget {
  final FormControlContext controlContext;
  FormSubmitButton({Key key, this.controlContext}) : super(key: key);

  _FormSubmitButtonState createState() => _FormSubmitButtonState();
}

class _FormSubmitButtonState extends State<FormSubmitButton> {
  @override
  Widget build(BuildContext context) {
    Map<String, dynamic> props = widget.controlContext.mergedProps;
    FormCreatorHandler formHandler = FormCreatorState.of(context);

    return 
    Container(
      margin: EdgeInsets.symmetric(horizontal: 10),
      child:  FlatButton(
        color: PrimaryColor,
        colorBrightness: Brightness.dark,
        child: Text(props["title"] ??= "提交", style: TextStyle(color: PrimaryTextColor)),
        onPressed: ()=> formHandler.submit(),
      )
    );
     
  }
}